package cn.ad.enumration;

import java.util.Map;

/**
 * User: shirongkang
 * Date: 2016/8/31
 * Time: 16:01
 * Desc:
 */
public enum Marriage {


    KIDS("育儿",1),
    BACHELORDOM("单身",2),
    NEWLYMARRIED("新婚",4),
    MARRIED("已婚",8);

    private String name;
    private int value;


    private static java.util.HashMap<String,Integer> mappings;

    private synchronized static java.util.HashMap<String, Integer> getMappings() {
        if (mappings == null) {
            mappings = new java.util.LinkedHashMap<String, Integer>();
            for (Marriage format : Marriage.values()) {
                mappings.put(format.name, format.value);
            }
        }
        return mappings;
    }

    private Marriage(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }
    public static Map<String,Integer> getMapping(){
        return getMappings();
    }
}
